package com.example.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * <p> JDK 动态代理 </p>
 *
 * @author Chris
 * @since 2022/11/29 10:09
 */
public class JdkDynamicProxy implements InvocationHandler {

    private final Object target;

    public JdkDynamicProxy(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("JDK 代理前");
        final Object invoke = method.invoke(target, args);
        System.out.println("JDK 代理后");
        return invoke;
    }

}